﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NS.BLL;

namespace Admin.Admin.UserMan
{
    public partial class UserList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IsLogin();

            Bind();
        }

        protected void Bind()
        {
            DataSet ds = new NS.BLL.Users().GetUserList();
            Users.DataSource = ds;
            Users.DataBind();
        }

        protected void UserList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.Users.PageIndex = e.NewPageIndex;
            Bind();
        }

        protected void IsAvailable_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList dp = sender as DropDownList;
            int userid = int.Parse(dp.Attributes["userid"].ToString());
            NS.BLL.Users userBll = new Users();
            NS.Model.Users userModel = userBll.GetModel(userid);
            userModel.IsAvailable = Convert.ToInt32(dp.SelectedValue);
            userBll.Update(userModel);
        }
    }
}